<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>seminar admin</title>
        <link href="../../script/seminar.css" rel="stylesheet"/>
        <script type="text/javascript">
            function fnLogOut() {
                document.seminarAdminForm.method = 'POST';
                document.seminarAdminForm.action = '../../logic/logout.php';
                document.seminarAdminForm.submit();
            }
            function fnSlctTopik() {
                var vIdxTema = document.getElementById("slctTopik").selectedIndex;
                var vIdTema = document.getElementById("slctTopik")[vIdxTema].value;
                document.seminarAdminForm.hidIdTopik.value = vIdTema;
                document.seminarAdminForm.method = 'POST';
                document.seminarAdminForm.action = '../../logic/getDetilSeminarAdmin.php';
                document.seminarAdminForm.submit();
            }
            function fnSimpanSeminar() {
                // simpan perubahan
                // flag_simpan = 1 ==> hidUbah = 2, simpan perubahan
                // flag_simpan = null ==> hidUbah = null, tambah seminar
                var vFlagSimpan = document.getElementById("hidFlagSimpan").value;
                if (vFlagSimpan == '1') {
                    var vIdxTema = document.getElementById("slctTopik").selectedIndex;
                    var vIdTema = document.getElementById("slctTopik")[vIdxTema].value;
                    var vIdxStsSeminar = document.getElementById("slctStsSeminar").selectedIndex;
                    var vIdStsSeminar = document.getElementById("slctStsSeminar")[vIdxStsSeminar].value;
                    document.seminarAdminForm.hidIdTopik.value = vIdTema;
                    document.seminarAdminForm.hidUbah.value = '2';
                    document.seminarAdminForm.hidStsSeminar.value = vIdStsSeminar;
                    document.seminarAdminForm.method = 'POST';
                    document.seminarAdminForm.action = '../../logic/ubahSeminarAdmin.php';
                    document.seminarAdminForm.submit();
                } else {
                    var vIdxStsSeminar = document.getElementById("slctStsSeminar").selectedIndex;
                    var vIdStsSeminar = document.getElementById("slctStsSeminar")[vIdxStsSeminar].value;
                    document.seminarAdminForm.hidUbah.value = '';
                    document.seminarAdminForm.hidStsSeminar.value = vIdStsSeminar;
                    document.seminarAdminForm.method = 'POST';
                    document.seminarAdminForm.action = '../../logic/addSeminarAdmin.php';
                    document.seminarAdminForm.submit();
                }
            }
            function fnUbahSeminar() {
                var vIdxTema = document.getElementById("slctTopik").selectedIndex;
                var vIdTema = document.getElementById("slctTopik")[vIdxTema].value;
                document.seminarAdminForm.hidIdTopik.value = vIdTema;
                document.seminarAdminForm.hidUbah.value = '1';
                document.seminarAdminForm.method = 'POST';
                document.seminarAdminForm.action = '../../logic/ubahSeminarAdmin.php';
                document.seminarAdminForm.submit();
            }
            function fnHapusSeminar() {
                var vIdxTema = document.getElementById("slctTopik").selectedIndex;
                var vIdTema = document.getElementById("slctTopik")[vIdxTema].value;
                document.seminarAdminForm.hidIdTopik.value = vIdTema;
                document.seminarAdminForm.method = 'POST';
                document.seminarAdminForm.action = '../../logic/hapusSeminarAdmin.php';
                document.seminarAdminForm.submit();
            }
        </script>
    </head>
    <body>
        <?php
        include("../../utility/connection.php");
        include("../../utility/general.php");
        include("../../model/mSeminar.php");
        session_start();
        if (isset($_SESSION['arrResult'])) {
            $arrResult = $_SESSION['arrResult'];
        ?>
        <form name="seminarAdminForm" id="seminarAdminForm">
        <input type="hidden" name="hidIdTopik" id="hidIdTopik">
        <input type="hidden" name="hidUbah" id="hidUbah">
        <input type="hidden" name="hidStsSeminar" id="hidStsSeminar">
        <table border="0" width="100%" height="100%">
            <tr valign="middle">
                <td align="center">
                    
                    <table width="90%" border="0" cellpadding="2" cellspacing="0">
                        <tr class="tbl-body">
                            <td width="25%">
                                <table width="100%" border="0" cellpadding="5" cellspacing="0">
                                    <tr class="tbl-header">
                                        <td>DAFTAR&nbsp;SEMINAR</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <select name="slctTopik" id="slctTopik" onchange="fnSlctTopik()" style="width: 200px" size="25">
                                                <?php
                                                $topikId = '';
                                                if (isset($_SESSION['topikId'])) {
                                                    $topikId = $_SESSION['topikId'];
                                                }
                                                
                                                $resultAllSeminar = fnSelectAllSeminar();
                                                if ($resultAllSeminar) {
                                                    while($rowSeminar = mysql_fetch_row($resultAllSeminar)){
                                                ?>
                                                <option value="<?php echo $rowSeminar[0] ?>" <?php echo ($topikId == $rowSeminar[0])? 'SELECTED':'' ?>><?php echo $rowSeminar[1] ?>
                                                <?php
                                                    }
                                                }
                                                ?>
                                            </select>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="75%">
                                <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0">
                                    <tr class="tbl-header">
                                        <td colspan="3">DETIL&nbsp;SEMINAR</td>
                                    </tr>
                                    <?php
                                    if (isset($_SESSION['seminarResult'])) {
                                        $detilSeminar = $_SESSION['seminarResult'];
                                        $tglOrig = $detilSeminar[4];
                                        $digitTgl = substr($tglOrig,-2,2);
                                        $digitBulan = fnConvertMonth(substr($tglOrig,-5,2));
                                        $digitTahun = substr($tglOrig,0,4);
                                        
                                        $tglAwalDaftar = $detilSeminar[6];
                                        $digitTgl1 = substr($tglAwalDaftar,-2,2);
                                        $digitBulan1 = fnConvertMonth(substr($tglAwalDaftar,-5,2));
                                        $digitTahun1 = substr($tglAwalDaftar,0,4);
                                        $TglDaftar1 = $digitTgl1.' '.$digitBulan1.' '.$digitTahun1;
                                        
                                        $tglAkhirDaftar = $detilSeminar[7];
                                        $digitTgl2 = substr($tglAkhirDaftar,-2,2);
                                        $digitBulan2 = fnConvertMonth(substr($tglAkhirDaftar,-5,2));
                                        $digitTahun2 = substr($tglAkhirDaftar,0,4);
                                        $TglDaftar2 = $digitTgl2.' '.$digitBulan2.' '.$digitTahun2;
                                        
                                        $stsSeminar = $detilSeminar[8];
                                        $StatusSeminar = '';
                                        if ($stsSeminar == '0') {
                                            $StatusSeminar = 'Tutup';
                                        } else if ($stsSeminar == '1') {
                                            $StatusSeminar = 'Buka';
                                        }
                                    ?>
                                    <tr class="tbl-body">
                                        <td>Tema</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><?php echo $detilSeminar[1] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Tanggal</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><?php echo $digitTgl ?>&nbsp;<?php echo $digitBulan ?>&nbsp;<?php echo $digitTahun ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Waktu</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><?php echo $detilSeminar[5] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Tanggal&nbsp;Pendaftaran</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><?php echo $TglDaftar1 ?>&nbsp;s.d.&nbsp;<?php echo $TglDaftar2 ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Tempat</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><?php echo $detilSeminar[3] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Uraian</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><textarea name="txtUraian" id="txtUraian" rows="13" cols="50" readonly="readonly"><?php echo $detilSeminar[2] ?></textarea></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Status</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><?php echo $StatusSeminar ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td colspan="3">
                                            <button type="button" name="btUbah" id="btUbah" onclick="fnUbahSeminar()">Ubah</button>
                                            <button type="button" name="btHapus" id="btHapus" onclick="fnHapusSeminar()">Hapus</button>
                                        </td>
                                    </tr>
                                    <?php 
                                    }
                                    ?>
                                </table>
                            </td>
                        </tr>
                        <tr class="tbl-body">
                            <td colspan="2">
                                <table width="100%" border="0" cellpadding="5" cellspacing="0">
                                    <tr class="tbl-header">
                                        <td colspan="3">TAMBAH&nbsp;SEMINAR</td>
                                    </tr>
                                    <?php
                                    $dummyFlag = 1;
                                    $Topik = '';
                                    $Detil_Topik = '';
                                    $Tempat = '';
                                    $Tanggal = '';
                                    $Waktu = '';
                                    $tglAwalDaftar = '';
                                    $tglAkhirDaftar = '';
                                    $Status = '';
                                    $FlagSimpan = '';
                                    if ($dummyFlag == 1) {
                                        if (isset($_SESSION['ubah'])) {
                                            $FlagSimpan = $_SESSION['ubah'];
                                            $ubahSeminar = $_SESSION['ubahSeminar'];
                                            $Topik = $ubahSeminar[1];
                                            $Detil_Topik = $ubahSeminar[2];
                                            $Tempat = $ubahSeminar[3];
                                            $Tanggal = $ubahSeminar[4];
                                            $Waktu = $ubahSeminar[5];
                                            
                                            $tglAwalDaftar = $ubahSeminar[6];
                                            $tglAkhirDaftar = $ubahSeminar[7];
                                            
                                            $Status = $ubahSeminar[8];
                                        }
                                    ?>
                                    <tr class="tbl-body">
                                        <td>Tema</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><input type="text" name="txtTema" id="txtTema" value="<?php echo $Topik ?>"></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Tanggal</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><input type="text" name="txtTanggal" id="txtTanggal" value="<?php echo $Tanggal ?>"></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Waktu</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><input type="text" name="txtWaktu" id="txtWaktu" value="<?php echo $Waktu ?>"></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Tanggal&nbsp;Pendaftaran</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td>
                                            <input type="text" name="txtTglAwalDaftar" id="txtTglAwalDaftar" value="<?php echo $tglAwalDaftar ?>">
                                            &nbsp;s.d.&nbsp;
                                            <input type="text" name="txtTglAkhirDaftar" id="txtTglAkhirDaftar" value="<?php echo $tglAkhirDaftar ?>">
                                        </td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Tempat</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><input type="text" name="txtTempat" id="txtTempat" value="<?php echo $Tempat ?>"></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Uraian</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td><textarea name="txtUraian" id="txtUraian" rows="5" cols="75"><?php echo $Detil_Topik ?></textarea></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Status</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td>
                                            <select name="slctStsSeminar" id="slctStsSeminar">
                                                <option value="0" <?php echo ($Status==0)?'SELECTED':'' ?>>Tutup</option>
                                                <option value="1" <?php echo ($Status==1)?'SELECTED':'' ?>>Buka</option>
                                            </select>
                                        </td>
                                    </tr>
                                   <tr class="tbl-body">
                                        <td colspan="3">
                                            <input type="hidden" name="hidFlagSimpan" id="hidFlagSimpan" value="<?php echo $FlagSimpan ?>">
                                            <button type="button" name="btSimpan" id="btSimpan" onclick="fnSimpanSeminar()">Simpan</button>
                                        </td>
                                    </tr>
                                     <?php
                                    }
                                    ?>
                                    
                                </table>
                            </td>
                        </tr>
                    </table>
                    
                </td>
            </tr>
            <tr valign="middle">
                <td align="center">
                    <button type="button" name="btLogOut" id="btLogOut" onclick="fnLogOut()">LogOut</button>
                </td>
            </tr>
        </table>
        </form>
        <?php
        }
        ?>
    </body>
</html>
